#@layout() #define main()
<div class="xp-layout">
	<div id="departmennt_form" class="layui-form">
		<div class="layui-form-pane">
			<div class="layui-inline xp-input-container">
				<label class="layui-form-label">考场</label>
				<div class="layui-input-inline">
					<input class="layui-input" type="text" name="name" id="name">
				</div>
			</div>
			<div class="layui-inline xp-input-container">
				<label class="layui-form-label">地市</label>
				<div class="layui-input-inline xp-select-container">
					<select id="shi" name="subject" lay-filter="changeType">
						<option value=' '>全部</option>
						<option value='太原市'>太原市</option>
						<option value='大同市'>大同市</option>
						<option value='阳泉市'>阳泉市</option>
						<option value='长治市'>长治市</option>
						<option value='晋城市'>晋城市</option>
						<option value='朔州市'>朔州市</option>
						<option value='吕梁市'>吕梁市</option>
						<option value='临汾市'>临汾市</option>
						<option value='晋中市'>晋中市</option>
						<option value='忻州市'>忻州市</option>
						<option value='运城市'>运城市</option>
					</select>
				</div>
			</div>
			
			
			<div class="layui-inline xp-input-container">
				<button class="layui-btn" data-type="reload" id="findDeptList">
					<i class="layui-icon">&#xe615;</i> 查询
				</button>
			</div>
		</div>
	</div>
	<table id="department_table" lay-filter="table_tool"></table>
	
</div>

<script type="text/html" id="barDemo"  >
  <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
</script>

<script type="text/html" id="switchTpl">
  		<!-- 这里的 checked 的状态只是演示 -->
  		<input type="checkbox" name="useStatus" value="{{d.ID}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="state_filter" {{ d.useStatus == 1 ? 'checked' : '' }}>
</script>
<script type="text/javascript">
	layui.use([ 'table', 'layer' ], function() {
		var table = layui.table, form = layui.form;

		//第一个实例
		table.render({
			id : 'dept_table',
			elem : '#department_table',
			url : 'exaSta/pagingData',
			even: true,
			limit:15,
			page : true,
			cols : [ [ {
				field : 'num',
				fixed : 'left',
				type : 'numbers'
			}, {
				field : 'shi',
				title : '地市',
				width:80
			}, {
				field : 'ownerUnit',
				title : '业主单位',
					width:550
			},  {
				field : 'k1s',
				title : '科目一',
				width:120,
				templet : function(d) {
					if (d.k1s == '1') {
						return '<span style="color: blue;">等待验收</span>';
					} else if (d.k1s == '2') {
							return '<span style="color: purple;">正在初验</span>';
					} else if (d.k1s == '3') {
							return '<span style="color: green;">初验通过</span>';
					}else if (d.k1s == '4') {
							return '<span style="color: red;">初验未通过</span>';
					}else{
						return '';
					}
				}
				
			},  {
				field : 'k2xs',
				title : '科目二(小车)',
				width:150,
				templet : function(d) {
					if (d.k2xs == '1') {
						return '<span style="color: blue;">等待验收</span>';
					} else if (d.k2xs == '2') {
							return '<span style="color: purple;">正在初验</span>';
					} else if (d.k2xs == '3') {
							return '<span style="color: green;">初验通过</span>';
					}else if (d.k2xs == '4') {
							return '<span style="color: red;">初验未通过</span>';
					}else{
						return '';
					}
				}
			},  {
				field : 'k2ds',
				title : '科目二(大车)',
				width:150,
				templet : function(d) {
					if (d.k2ds == '1') {
						return '<span style="color: blue;">等待验收</span>';
					} else if (d.k2ds == '2') {
							return '<span style="color: purple;">正在初验</span>';
					} else if (d.k2ds == '3') {
							return '<span style="color: green;">初验通过</span>';
					}else if (d.k2ds == '4') {
							return '<span style="color: red;">初验未通过</span>';
					}else{
						return '';
					}
				}
			},  {
				field : 'k3s',
				title : '科目三',
				width:120,
				templet : function(d) {
					if (d.k3s == '1') {
						return '<span style="color: blue;">等待验收</span>';
					} else if (d.k3s == '2') {
							return '<span style="color: purple;">正在初验</span>';
					} else if (d.k3s == '3') {
							return '<span style="color: green;">初验通过</span>';
					}else if (d.k3s == '4') {
							return '<span style="color: red;">初验未通过</span>';
					}else{
						return '';
					}
				}
			},  {
				field : 'k4s',
				title : '科目四',
				width:120,
				templet : function(d) {
					if (d.k4s == '1') {
						return '<span style="color: blue;">等待验收</span>';
					} else if (d.k4s == '2') {
							return '<span style="color: purple;">正在初验</span>';
					} else if (d.k4s == '3') {
							return '<span style="color: green;">初验通过</span>';
					}else if (d.k4s == '4') {
							return '<span style="color: red;">初验未通过</span>';
					}else{
						return '';
					}
				}
			}  ] ]
		});

		//监听工具条
		table.on('tool(table_tool)', function(obj) {
			var data = obj.data;
			if (obj.event === 'detail') {
				layer.msg('ID：' + data.ID + ' 的查看操作');
			} else if (obj.event === 'del') {
				layer.confirm('真的删除行么', function(index) {
					obj.del();
					layer.close(index);
				});
			} else if (obj.event === 'edit') {
				layer.open({
					type : 2,
					title : '修改考场',
					area : [ '100%', '100%' ],
					shade : 0,
					id : 'deptEdit_iframe',
					content : 'ysht/updateExamination.html?ID=' + data.ID,
					//content : 'newExa/edit_ui?ID=' + data.ID,
					zIndex : layer.zIndex,
					success : function(layero) {
						layer.setTop(layero);
					}
				});
			}
		});

		var $ = layui.$, active = {
			reload : function() {

				//执行重载
				table.reload('dept_table', {
					page : {
						curr : 1
					},
					where : {
						name : $('#name').val(),
						shi : $('#shi').val(),
					}
				});
			}
		};

		$('#departmennt_form .layui-btn').on('click', function() {
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
		});

		$('#addDept').on('click', function() {
			 layer.open({
				type : 2,
				title : '添加考场',
				area : [ '100%', '100%' ],
				shade : 0,
				id : 'deptAdd_iframe',
				content : 'ysht/examination.html',
				zIndex : layer.zIndex,
				success : function(layero) {
					layer.setTop(layero);
				}
			}); 
		});
		
		
		/* $('#addDept').on('click', function() {
			layer.open({
				type : 2,
				title : '添加科二考场',
				area : [ '100%', '100%' ],
				shade : 0,
				id : 'deptAdd_iframe',
				content : 'newExa/add_uik2',
				zIndex : layer.zIndex,
				success : function(layero) {
					layer.setTop(layero);
				}
			});
		});
		
		
		$('#addDept').on('click', function() {
			layer.open({
				type : 2,
				title : '添加科三考场',
				area : [ '100%', '100%' ],
				shade : 0,
				id : 'deptAdd_iframe',
				content : 'newExa/add_uik3',
				zIndex : layer.zIndex,
				success : function(layero) {
					layer.setTop(layero);
				}
			});
		});
 */
		//监听性别操作
		form.on('switch(state_filter)', function(obj) {
			// 			layer.tips(this.value + ' ' + this.name + '：' + obj.elem.checked, obj.othis);
			var state;
			if (obj.elem.checked == false) {
				state = 0;
			} else {
				state = 1;
			}
			var url = 'newExa/editState';
			$.post(url, {
				ID : this.value,
				state : state
			}, function(res) {
				if (res.result == 1) {
					layer.tips(res.msg, obj.othis);
				} else {
				}
			});
		});
	});

	function reloadList() {
		$('#findDeptList').click();
	}
	
	function tzym(eid,kms,check,yzm){
		/* if($("#"+eid).val()==null||$("#"+eid).val()==''){
			alert("请填写验证码！");
			return false;
		} */
		 if(check=='1'){
			 window.location.href='ysht/Rectificationys'+kms+'.html?id='+eid+'&checkStatus=1&subject='+kms;
		}else if(check=='2'){
			 window.location.href='ysht/Rectificationys'+kms+'.html?id='+eid+'&checkStatus=2&subject='+kms;
		}else{
			alert("验证码错误！无权限访问");
		} 
	}
</script>

#end
